package com.fy.controller;


import com.fy.entity.Comments;

import com.fy.dao.CommentsMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/comments")
public class CommentsController {
    String id = "1";
    @Resource
    CommentsMapper commentsMapper;
    @GetMapping("/getAll")
    public List<Comments> commentsMapper(){
        List<Comments> co =commentsMapper.findAll();
        return co;
    }
    @PostMapping("/getInfo")
    public List<Comments> comments(String co_id){
        List<Comments> co=commentsMapper.getInfo(co_id);
        return co;
    }
    @PostMapping(value = "/insert")
    public String insert (String co_id,String info_id,String co_info,String for_id){
        commentsMapper.insert_comments(id,info_id,co_info,for_id);
        id=(Integer.valueOf(id)+1+"");
        return "200";
    }
    @PostMapping("/delete")
    public String delete(String co_id){
        commentsMapper.delete_comments(co_id);
        return "200";
    }
    @PostMapping("/update")
    public int update(String co_info, String info_id){
        return commentsMapper.update_comments(co_info,info_id);
        }
    }

